package com.aspose.cells;

import java.util.ArrayList;
import java.util.Iterator;

public class SparklineGroupCollection extends CollectionBase {
   private Worksheet b;

   SparklineGroupCollection(Worksheet sheet) {
      this.b = sheet;
   }

   Worksheet a() {
      return this.b;
   }

   public SparklineGroup get(int index) {
      return (SparklineGroup)this.a.get(index);
   }

   public int add(int type, String dataRange, boolean isVertical, CellArea locationRange) {
      this.clearSparklines(locationRange);
      SparklineGroup var5 = new SparklineGroup(this, type, dataRange, isVertical, locationRange);
      com.aspose.cells.b.a.a.ze.a(this.a, (Object)var5);
      return this.getCount() - 1;
   }

   int a(SparklineGroup var1) {
      com.aspose.cells.b.a.a.ze.a(this.a, (Object)var1);
      return this.getCount() - 1;
   }

   void b() {
      ArrayList var1 = new ArrayList();
      Iterator var2 = this.iterator();

      SparklineGroup var3;
      while(var2.hasNext()) {
         var3 = (SparklineGroup)var2.next();
         SparklineCollection var4 = var3.getSparklineCollection();
         if (var4.getCount() == 0) {
            com.aspose.cells.b.a.a.ze.a(var1, (Object)var3);
         }
      }

      var2 = var1.iterator();

      while(var2.hasNext()) {
         var3 = (SparklineGroup)var2.next();
         this.a.remove(var3);
      }

   }

   public void clearSparklines(CellArea cellArea) {
      ArrayList var2 = new ArrayList();
      Iterator var3 = this.iterator();

      SparklineGroup var4;
      while(var3.hasNext()) {
         var4 = (SparklineGroup)var3.next();
         SparklineCollection var5 = var4.getSparklineCollection();
         ArrayList var6 = new ArrayList();
         Iterator var7 = var5.iterator();

         Sparkline var8;
         while(var7.hasNext()) {
            var8 = (Sparkline)var7.next();
            if (var8.a(cellArea)) {
               com.aspose.cells.b.a.a.ze.a(var6, (Object)var8);
            }
         }

         var7 = var6.iterator();

         while(var7.hasNext()) {
            var8 = (Sparkline)var7.next();
            var5.remove(var8);
         }

         if (var5.getCount() == 0) {
            com.aspose.cells.b.a.a.ze.a(var2, (Object)var4);
         }
      }

      var3 = var2.iterator();

      while(var3.hasNext()) {
         var4 = (SparklineGroup)var3.next();
         this.a.remove(var4);
      }

   }

   public void clearSparklineGroups(CellArea cellArea) {
      ArrayList var2 = new ArrayList();
      Iterator var3 = this.iterator();

      while(true) {
         SparklineGroup var4;
         while(var3.hasNext()) {
            var4 = (SparklineGroup)var3.next();
            SparklineCollection var5 = var4.getSparklineCollection();
            Iterator var6 = var5.iterator();

            while(var6.hasNext()) {
               Sparkline var7 = (Sparkline)var6.next();
               if (var7.a(cellArea)) {
                  com.aspose.cells.b.a.a.ze.a(var2, (Object)var4);
                  break;
               }
            }
         }

         var3 = var2.iterator();

         while(var3.hasNext()) {
            var4 = (SparklineGroup)var3.next();
            this.a.remove(var4);
         }

         return;
      }
   }

   void c() {
      for(int var1 = 0; var1 < this.getCount(); ++var1) {
         SparklineGroup var2 = this.get(var1);
         if (var2.b() != null) {
            zboa var3 = var2.b();
            if (var3.a != null) {
               var3.a = zcq.a(var3.a, -1, 0, 0, false);
            }
         }

         Iterator var6 = var2.getSparklineCollection().iterator();

         while(var6.hasNext()) {
            Sparkline var4 = (Sparkline)var6.next();
            zboa var5 = var4.a();
            if (var5 != null && var5.a != null) {
               var5.a = zcq.a(var5.a, -1, 0, 0, false);
            }
         }
      }

   }

   void d() {
      for(int var1 = 0; var1 < this.getCount(); ++var1) {
         SparklineGroup var2 = this.get(var1);
         if (var2.b() != null) {
            zboa var3 = var2.b();
            if (var3.a != null) {
               var3.a = zcr.a(var3.a, -1);
            }
         }

         Iterator var6 = var2.getSparklineCollection().iterator();

         while(var6.hasNext()) {
            Sparkline var4 = (Sparkline)var6.next();
            zboa var5 = var4.a();
            if (var5 != null && var5.a != null) {
               var5.a = zcr.a(var5.a, -1);
            }
         }
      }

   }

   void a(Cells var1, int var2, int var3, boolean var4) {
      for(int var5 = 0; var5 < this.a.size(); ++var5) {
         if (this.get(var5).a(var1, var2, var3, var4) == 0) {
            this.a.remove(this.get(var5));
         }
      }

   }

   void b(Cells var1, int var2, int var3, boolean var4) {
      for(int var5 = 0; var5 < this.a.size(); ++var5) {
         if (this.get(var5).b(var1, var2, var3, var4) == 0) {
            this.a.remove(this.get(var5));
         }
      }

   }

   void a(SparklineGroupCollection var1, boolean var2, int var3, int var4, int var5, CopyOptions var6) {
      int var7 = var1.getCount();

      for(int var8 = 0; var8 < var7; ++var8) {
         SparklineGroup var9 = var1.get(var8);
         boolean var10 = false;

         for(int var11 = 0; var11 < var9.getSparklineCollection().getCount(); ++var11) {
            Sparkline var12 = var9.getSparklineCollection().get(var11);
            int var13 = var2 ? var12.getRow() : var12.getColumn();
            if (var13 >= var3 && var13 <= var3 + var5 - 1) {
               var10 = true;
               break;
            }
         }

         if (var10) {
            SparklineGroup var14 = new SparklineGroup(this);
            this.a(var14);
            var14.a(var9, var2, var3, var4, var5, var6);
         }
      }

   }

   void a(SparklineGroupCollection var1, CopyOptions var2) {
      for(int var3 = 0; var3 < var1.getCount(); ++var3) {
         SparklineGroup var4 = var1.get(var3);
         SparklineGroup var5 = new SparklineGroup(this);
         this.a(var5);
         var5.b(var4, var2);
      }

   }
}
